<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>basetestchannel.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_labs_net_webchannel_basetestchannel.js.html">basetestchannel.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Base TestChannel implementation.
<a name="line17"></a> *
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>
<a name="line21"></a>goog.provide(&#39;goog.labs.net.webChannel.BaseTestChannel&#39;);
<a name="line22"></a>
<a name="line23"></a>goog.require(&#39;goog.labs.net.webChannel.Channel&#39;);
<a name="line24"></a>goog.require(&#39;goog.labs.net.webChannel.ChannelRequest&#39;);
<a name="line25"></a>goog.require(&#39;goog.labs.net.webChannel.requestStats&#39;);
<a name="line26"></a>goog.require(&#39;goog.labs.net.webChannel.requestStats.Stat&#39;);
<a name="line27"></a>
<a name="line28"></a>
<a name="line29"></a>
<a name="line30"></a>/**
<a name="line31"></a> * A TestChannel is used during the first part of channel negotiation
<a name="line32"></a> * with the server to create the channel. It helps us determine whether we&#39;re
<a name="line33"></a> * behind a buffering proxy.
<a name="line34"></a> *
<a name="line35"></a> * @constructor
<a name="line36"></a> * @struct
<a name="line37"></a> * @param {!goog.labs.net.webChannel.Channel} channel The channel
<a name="line38"></a> *     that owns this test channel.
<a name="line39"></a> * @param {!goog.labs.net.webChannel.WebChannelDebug} channelDebug A
<a name="line40"></a> *     WebChannelDebug instance to use for logging.
<a name="line41"></a> * @implements {goog.labs.net.webChannel.Channel}
<a name="line42"></a> */
<a name="line43"></a>goog.labs.net.webChannel.BaseTestChannel = function(channel, channelDebug) {
<a name="line44"></a>  /**
<a name="line45"></a>   * The channel that owns this test channel
<a name="line46"></a>   * @private {!goog.labs.net.webChannel.Channel}
<a name="line47"></a>   */
<a name="line48"></a>  this.channel_ = channel;
<a name="line49"></a>
<a name="line50"></a>  /**
<a name="line51"></a>   * The channel debug to use for logging
<a name="line52"></a>   * @private {!goog.labs.net.webChannel.WebChannelDebug}
<a name="line53"></a>   */
<a name="line54"></a>  this.channelDebug_ = channelDebug;
<a name="line55"></a>};
<a name="line56"></a>
<a name="line57"></a>
<a name="line58"></a>goog.scope(function() {
<a name="line59"></a>var BaseTestChannel = goog.labs.net.webChannel.BaseTestChannel;
<a name="line60"></a>var WebChannelDebug = goog.labs.net.webChannel.WebChannelDebug;
<a name="line61"></a>var ChannelRequest = goog.labs.net.webChannel.ChannelRequest;
<a name="line62"></a>var requestStats = goog.labs.net.webChannel.requestStats;
<a name="line63"></a>var Channel = goog.labs.net.webChannel.Channel;
<a name="line64"></a>
<a name="line65"></a>
<a name="line66"></a>/**
<a name="line67"></a> * Extra HTTP headers to add to all the requests sent to the server.
<a name="line68"></a> * @type {Object}
<a name="line69"></a> * @private
<a name="line70"></a> */
<a name="line71"></a>BaseTestChannel.prototype.extraHeaders_ = null;
<a name="line72"></a>
<a name="line73"></a>
<a name="line74"></a>/**
<a name="line75"></a> * The test request.
<a name="line76"></a> * @type {ChannelRequest}
<a name="line77"></a> * @private
<a name="line78"></a> */
<a name="line79"></a>BaseTestChannel.prototype.request_ = null;
<a name="line80"></a>
<a name="line81"></a>
<a name="line82"></a>/**
<a name="line83"></a> * Whether we have received the first result as an intermediate result. This
<a name="line84"></a> * helps us determine whether we&#39;re behind a buffering proxy.
<a name="line85"></a> * @type {boolean}
<a name="line86"></a> * @private
<a name="line87"></a> */
<a name="line88"></a>BaseTestChannel.prototype.receivedIntermediateResult_ = false;
<a name="line89"></a>
<a name="line90"></a>
<a name="line91"></a>/**
<a name="line92"></a> * The time when the test request was started. We use timing in IE as
<a name="line93"></a> * a heuristic for whether we&#39;re behind a buffering proxy.
<a name="line94"></a> * @type {?number}
<a name="line95"></a> * @private
<a name="line96"></a> */
<a name="line97"></a>BaseTestChannel.prototype.startTime_ = null;
<a name="line98"></a>
<a name="line99"></a>
<a name="line100"></a>/**
<a name="line101"></a> * The time for of the first result part. We use timing in IE as a
<a name="line102"></a> * heuristic for whether we&#39;re behind a buffering proxy.
<a name="line103"></a> * @type {?number}
<a name="line104"></a> * @private
<a name="line105"></a> */
<a name="line106"></a>BaseTestChannel.prototype.firstTime_ = null;
<a name="line107"></a>
<a name="line108"></a>
<a name="line109"></a>/**
<a name="line110"></a> * The time for of the last result part. We use timing in IE as a
<a name="line111"></a> * heuristic for whether we&#39;re behind a buffering proxy.
<a name="line112"></a> * @type {?number}
<a name="line113"></a> * @private
<a name="line114"></a> */
<a name="line115"></a>BaseTestChannel.prototype.lastTime_ = null;
<a name="line116"></a>
<a name="line117"></a>
<a name="line118"></a>/**
<a name="line119"></a> * The relative path for test requests.
<a name="line120"></a> * @type {?string}
<a name="line121"></a> * @private
<a name="line122"></a> */
<a name="line123"></a>BaseTestChannel.prototype.path_ = null;
<a name="line124"></a>
<a name="line125"></a>
<a name="line126"></a>/**
<a name="line127"></a> * The state of the state machine for this object.
<a name="line128"></a> *
<a name="line129"></a> * @type {?number}
<a name="line130"></a> * @private
<a name="line131"></a> */
<a name="line132"></a>BaseTestChannel.prototype.state_ = null;
<a name="line133"></a>
<a name="line134"></a>
<a name="line135"></a>/**
<a name="line136"></a> * The last status code received.
<a name="line137"></a> * @type {number}
<a name="line138"></a> * @private
<a name="line139"></a> */
<a name="line140"></a>BaseTestChannel.prototype.lastStatusCode_ = -1;
<a name="line141"></a>
<a name="line142"></a>
<a name="line143"></a>/**
<a name="line144"></a> * A subdomain prefix for using a subdomain in IE for the backchannel
<a name="line145"></a> * requests.
<a name="line146"></a> * @type {?string}
<a name="line147"></a> * @private
<a name="line148"></a> */
<a name="line149"></a>BaseTestChannel.prototype.hostPrefix_ = null;
<a name="line150"></a>
<a name="line151"></a>
<a name="line152"></a>/**
<a name="line153"></a> * Enum type for the test channel state machine
<a name="line154"></a> * @enum {number}
<a name="line155"></a> * @private
<a name="line156"></a> */
<a name="line157"></a>BaseTestChannel.State_ = {
<a name="line158"></a>  /**
<a name="line159"></a>   * The state for the TestChannel state machine where we making the
<a name="line160"></a>   * initial call to get the server configured parameters.
<a name="line161"></a>   */
<a name="line162"></a>  INIT: 0,
<a name="line163"></a>
<a name="line164"></a>  /**
<a name="line165"></a>   * The  state for the TestChannel state machine where we&#39;re checking to
<a name="line166"></a>   * se if we&#39;re behind a buffering proxy.
<a name="line167"></a>   */
<a name="line168"></a>  CONNECTION_TESTING: 1
<a name="line169"></a>};
<a name="line170"></a>
<a name="line171"></a>
<a name="line172"></a>/**
<a name="line173"></a> * Time between chunks in the test connection that indicates that we
<a name="line174"></a> * are not behind a buffering proxy. This value should be less than or
<a name="line175"></a> * equals to the time between chunks sent from the server.
<a name="line176"></a> * @type {number}
<a name="line177"></a> * @private
<a name="line178"></a> */
<a name="line179"></a>BaseTestChannel.MIN_TIME_EXPECTED_BETWEEN_DATA_ = 500;
<a name="line180"></a>
<a name="line181"></a>
<a name="line182"></a>/**
<a name="line183"></a> * Sets extra HTTP headers to add to all the requests sent to the server.
<a name="line184"></a> *
<a name="line185"></a> * @param {Object} extraHeaders The HTTP headers.
<a name="line186"></a> */
<a name="line187"></a>BaseTestChannel.prototype.setExtraHeaders = function(extraHeaders) {
<a name="line188"></a>  this.extraHeaders_ = extraHeaders;
<a name="line189"></a>};
<a name="line190"></a>
<a name="line191"></a>
<a name="line192"></a>/**
<a name="line193"></a> * Starts the test channel. This initiates connections to the server.
<a name="line194"></a> *
<a name="line195"></a> * @param {string} path The relative uri for the test connection.
<a name="line196"></a> */
<a name="line197"></a>BaseTestChannel.prototype.connect = function(path) {
<a name="line198"></a>  this.path_ = path;
<a name="line199"></a>  var sendDataUri = this.channel_.getForwardChannelUri(this.path_);
<a name="line200"></a>
<a name="line201"></a>  requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_ONE_START);
<a name="line202"></a>  this.startTime_ = goog.now();
<a name="line203"></a>
<a name="line204"></a>  // If the channel already has the result of the handshake, then skip it.
<a name="line205"></a>  var handshakeResult = this.channel_.getConnectionState().handshakeResult;
<a name="line206"></a>  if (goog.isDefAndNotNull(handshakeResult)) {
<a name="line207"></a>    this.hostPrefix_ = this.channel_.correctHostPrefix(handshakeResult[0]);
<a name="line208"></a>    this.state_ = BaseTestChannel.State_.CONNECTION_TESTING;
<a name="line209"></a>    this.checkBufferingProxy_();
<a name="line210"></a>    return;
<a name="line211"></a>  }
<a name="line212"></a>
<a name="line213"></a>  // the first request returns server specific parameters
<a name="line214"></a>  sendDataUri.setParameterValues(&#39;MODE&#39;, &#39;init&#39;);
<a name="line215"></a>  this.request_ = ChannelRequest.createChannelRequest(this, this.channelDebug_);
<a name="line216"></a>  this.request_.setExtraHeaders(this.extraHeaders_);
<a name="line217"></a>  this.request_.xmlHttpGet(sendDataUri, false /* decodeChunks */,
<a name="line218"></a>      null /* hostPrefix */, true /* opt_noClose */);
<a name="line219"></a>  this.state_ = BaseTestChannel.State_.INIT;
<a name="line220"></a>};
<a name="line221"></a>
<a name="line222"></a>
<a name="line223"></a>/**
<a name="line224"></a> * Begins the second stage of the test channel where we test to see if we&#39;re
<a name="line225"></a> * behind a buffering proxy. The server sends back a multi-chunked response
<a name="line226"></a> * with the first chunk containing the content &#39;1&#39; and then two seconds later
<a name="line227"></a> * sending the second chunk containing the content &#39;2&#39;. Depending on how we
<a name="line228"></a> * receive the content, we can tell if we&#39;re behind a buffering proxy.
<a name="line229"></a> * @private
<a name="line230"></a> */
<a name="line231"></a>BaseTestChannel.prototype.checkBufferingProxy_ = function() {
<a name="line232"></a>  this.channelDebug_.debug(&#39;TestConnection: starting stage 2&#39;);
<a name="line233"></a>
<a name="line234"></a>  // If the test result is already available, skip its execution.
<a name="line235"></a>  var bufferingProxyResult =
<a name="line236"></a>      this.channel_.getConnectionState().bufferingProxyResult;
<a name="line237"></a>  if (goog.isDefAndNotNull(bufferingProxyResult)) {
<a name="line238"></a>    this.channelDebug_.debug(
<a name="line239"></a>        &#39;TestConnection: skipping stage 2, precomputed result is &#39; +
<a name="line240"></a>        bufferingProxyResult ? &#39;Buffered&#39; : &#39;Unbuffered&#39;);
<a name="line241"></a>    requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_TWO_START);
<a name="line242"></a>    if (bufferingProxyResult) { // Buffered/Proxy connection
<a name="line243"></a>      requestStats.notifyStatEvent(requestStats.Stat.PROXY);
<a name="line244"></a>      this.channel_.testConnectionFinished(this, false);
<a name="line245"></a>    } else { // Unbuffered/NoProxy connection
<a name="line246"></a>      requestStats.notifyStatEvent(requestStats.Stat.NOPROXY);
<a name="line247"></a>      this.channel_.testConnectionFinished(this, true);
<a name="line248"></a>    }
<a name="line249"></a>    return; // Skip the test
<a name="line250"></a>  }
<a name="line251"></a>  this.request_ = ChannelRequest.createChannelRequest(this, this.channelDebug_);
<a name="line252"></a>  this.request_.setExtraHeaders(this.extraHeaders_);
<a name="line253"></a>  var recvDataUri = this.channel_.getBackChannelUri(this.hostPrefix_,
<a name="line254"></a>      /** @type {string} */ (this.path_));
<a name="line255"></a>
<a name="line256"></a>  requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_TWO_START);
<a name="line257"></a>  if (!ChannelRequest.supportsXhrStreaming()) {
<a name="line258"></a>    recvDataUri.setParameterValues(&#39;TYPE&#39;, &#39;html&#39;);
<a name="line259"></a>    this.request_.tridentGet(recvDataUri, Boolean(this.hostPrefix_));
<a name="line260"></a>  } else {
<a name="line261"></a>    recvDataUri.setParameterValues(&#39;TYPE&#39;, &#39;xmlhttp&#39;);
<a name="line262"></a>    this.request_.xmlHttpGet(recvDataUri, false /** decodeChunks */,
<a name="line263"></a>        this.hostPrefix_, false /** opt_noClose */);
<a name="line264"></a>  }
<a name="line265"></a>};
<a name="line266"></a>
<a name="line267"></a>
<a name="line268"></a>/**
<a name="line269"></a> * @override
<a name="line270"></a> */
<a name="line271"></a>BaseTestChannel.prototype.createXhrIo = function(hostPrefix) {
<a name="line272"></a>  return this.channel_.createXhrIo(hostPrefix);
<a name="line273"></a>};
<a name="line274"></a>
<a name="line275"></a>
<a name="line276"></a>/**
<a name="line277"></a> * Aborts the test channel.
<a name="line278"></a> */
<a name="line279"></a>BaseTestChannel.prototype.abort = function() {
<a name="line280"></a>  if (this.request_) {
<a name="line281"></a>    this.request_.cancel();
<a name="line282"></a>    this.request_ = null;
<a name="line283"></a>  }
<a name="line284"></a>  this.lastStatusCode_ = -1;
<a name="line285"></a>};
<a name="line286"></a>
<a name="line287"></a>
<a name="line288"></a>/**
<a name="line289"></a> * Returns whether the test channel is closed. The ChannelRequest object expects
<a name="line290"></a> * this method to be implemented on its handler.
<a name="line291"></a> *
<a name="line292"></a> * @return {boolean} Whether the channel is closed.
<a name="line293"></a> * @override
<a name="line294"></a> */
<a name="line295"></a>BaseTestChannel.prototype.isClosed = function() {
<a name="line296"></a>  return false;
<a name="line297"></a>};
<a name="line298"></a>
<a name="line299"></a>
<a name="line300"></a>/**
<a name="line301"></a> * Callback from ChannelRequest for when new data is received
<a name="line302"></a> *
<a name="line303"></a> * @param {ChannelRequest} req The request object.
<a name="line304"></a> * @param {string} responseText The text of the response.
<a name="line305"></a> * @override
<a name="line306"></a> */
<a name="line307"></a>BaseTestChannel.prototype.onRequestData = function(req, responseText) {
<a name="line308"></a>  this.lastStatusCode_ = req.getLastStatusCode();
<a name="line309"></a>  if (this.state_ == BaseTestChannel.State_.INIT) {
<a name="line310"></a>    this.channelDebug_.debug(&#39;TestConnection: Got data for stage 1&#39;);
<a name="line311"></a>    if (!responseText) {
<a name="line312"></a>      this.channelDebug_.debug(&#39;TestConnection: Null responseText&#39;);
<a name="line313"></a>      // The server should always send text; something is wrong here
<a name="line314"></a>      this.channel_.testConnectionFailure(this, ChannelRequest.Error.BAD_DATA);
<a name="line315"></a>      return;
<a name="line316"></a>    }
<a name="line317"></a>    /** @preserveTry */
<a name="line318"></a>    try {
<a name="line319"></a>      var respArray = this.channel_.getWireCodec().decodeMessage(responseText);
<a name="line320"></a>    } catch (e) {
<a name="line321"></a>      this.channelDebug_.dumpException(e);
<a name="line322"></a>      this.channel_.testConnectionFailure(this, ChannelRequest.Error.BAD_DATA);
<a name="line323"></a>      return;
<a name="line324"></a>    }
<a name="line325"></a>    this.hostPrefix_ = this.channel_.correctHostPrefix(respArray[0]);
<a name="line326"></a>  } else if (this.state_ == BaseTestChannel.State_.CONNECTION_TESTING) {
<a name="line327"></a>    if (this.receivedIntermediateResult_) {
<a name="line328"></a>      requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_TWO_DATA_TWO);
<a name="line329"></a>      this.lastTime_ = goog.now();
<a name="line330"></a>    } else {
<a name="line331"></a>      // &#39;11111&#39; is used instead of &#39;1&#39; to prevent a small amount of buffering
<a name="line332"></a>      // by Safari.
<a name="line333"></a>      if (responseText == &#39;11111&#39;) {
<a name="line334"></a>        requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_TWO_DATA_ONE);
<a name="line335"></a>        this.receivedIntermediateResult_ = true;
<a name="line336"></a>        this.firstTime_ = goog.now();
<a name="line337"></a>        if (this.checkForEarlyNonBuffered_()) {
<a name="line338"></a>          // If early chunk detection is on, and we passed the tests,
<a name="line339"></a>          // assume HTTP_OK, cancel the test and turn on noproxy mode.
<a name="line340"></a>          this.lastStatusCode_ = 200;
<a name="line341"></a>          this.request_.cancel();
<a name="line342"></a>          this.channelDebug_.debug(
<a name="line343"></a>              &#39;Test connection succeeded; using streaming connection&#39;);
<a name="line344"></a>          requestStats.notifyStatEvent(requestStats.Stat.NOPROXY);
<a name="line345"></a>          this.channel_.testConnectionFinished(this, true);
<a name="line346"></a>        }
<a name="line347"></a>      } else {
<a name="line348"></a>        requestStats.notifyStatEvent(
<a name="line349"></a>            requestStats.Stat.TEST_STAGE_TWO_DATA_BOTH);
<a name="line350"></a>        this.firstTime_ = this.lastTime_ = goog.now();
<a name="line351"></a>        this.receivedIntermediateResult_ = false;
<a name="line352"></a>      }
<a name="line353"></a>    }
<a name="line354"></a>  }
<a name="line355"></a>};
<a name="line356"></a>
<a name="line357"></a>
<a name="line358"></a>/**
<a name="line359"></a> * Callback from ChannelRequest that indicates a request has completed.
<a name="line360"></a> *
<a name="line361"></a> * @param {ChannelRequest} req The request object.
<a name="line362"></a> * @override
<a name="line363"></a> */
<a name="line364"></a>BaseTestChannel.prototype.onRequestComplete = function(req) {
<a name="line365"></a>  this.lastStatusCode_ = this.request_.getLastStatusCode();
<a name="line366"></a>  if (!this.request_.getSuccess()) {
<a name="line367"></a>    this.channelDebug_.debug(
<a name="line368"></a>        &#39;TestConnection: request failed, in state &#39; + this.state_);
<a name="line369"></a>    if (this.state_ == BaseTestChannel.State_.INIT) {
<a name="line370"></a>      requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_ONE_FAILED);
<a name="line371"></a>    } else if (this.state_ == BaseTestChannel.State_.CONNECTION_TESTING) {
<a name="line372"></a>      requestStats.notifyStatEvent(requestStats.Stat.TEST_STAGE_TWO_FAILED);
<a name="line373"></a>    }
<a name="line374"></a>    this.channel_.testConnectionFailure(this,
<a name="line375"></a>        /** @type {ChannelRequest.Error} */
<a name="line376"></a>        (this.request_.getLastError()));
<a name="line377"></a>    return;
<a name="line378"></a>  }
<a name="line379"></a>
<a name="line380"></a>  if (this.state_ == BaseTestChannel.State_.INIT) {
<a name="line381"></a>    this.channelDebug_.debug(
<a name="line382"></a>        &#39;TestConnection: request complete for initial check&#39;);
<a name="line383"></a>    this.state_ = BaseTestChannel.State_.CONNECTION_TESTING;
<a name="line384"></a>    this.checkBufferingProxy_();
<a name="line385"></a>  } else if (this.state_ == BaseTestChannel.State_.CONNECTION_TESTING) {
<a name="line386"></a>    this.channelDebug_.debug(&#39;TestConnection: request complete for stage 2&#39;);
<a name="line387"></a>    var goodConn = false;
<a name="line388"></a>
<a name="line389"></a>    if (!ChannelRequest.supportsXhrStreaming()) {
<a name="line390"></a>      // we always get Trident responses in separate calls to
<a name="line391"></a>      // onRequestData, so we have to check the time they came
<a name="line392"></a>      var ms = this.lastTime_ - this.firstTime_;
<a name="line393"></a>      if (ms &lt; 200) {
<a name="line394"></a>        // TODO: need to empirically verify that this number is OK
<a name="line395"></a>        // for slow computers
<a name="line396"></a>        goodConn = false;
<a name="line397"></a>      } else {
<a name="line398"></a>        goodConn = true;
<a name="line399"></a>      }
<a name="line400"></a>    } else {
<a name="line401"></a>      goodConn = this.receivedIntermediateResult_;
<a name="line402"></a>    }
<a name="line403"></a>
<a name="line404"></a>    if (goodConn) {
<a name="line405"></a>      this.channelDebug_.debug(
<a name="line406"></a>          &#39;Test connection succeeded; using streaming connection&#39;);
<a name="line407"></a>      requestStats.notifyStatEvent(requestStats.Stat.NOPROXY);
<a name="line408"></a>      this.channel_.testConnectionFinished(this, true);
<a name="line409"></a>    } else {
<a name="line410"></a>      this.channelDebug_.debug(
<a name="line411"></a>          &#39;Test connection failed; not using streaming&#39;);
<a name="line412"></a>      requestStats.notifyStatEvent(requestStats.Stat.PROXY);
<a name="line413"></a>      this.channel_.testConnectionFinished(this, false);
<a name="line414"></a>    }
<a name="line415"></a>  }
<a name="line416"></a>};
<a name="line417"></a>
<a name="line418"></a>
<a name="line419"></a>/**
<a name="line420"></a> * Returns the last status code received for a request.
<a name="line421"></a> * @return {number} The last status code received for a request.
<a name="line422"></a> */
<a name="line423"></a>BaseTestChannel.prototype.getLastStatusCode = function() {
<a name="line424"></a>  return this.lastStatusCode_;
<a name="line425"></a>};
<a name="line426"></a>
<a name="line427"></a>
<a name="line428"></a>/**
<a name="line429"></a> * @return {boolean} Whether we should be using secondary domains when the
<a name="line430"></a> *     server instructs us to do so.
<a name="line431"></a> * @override
<a name="line432"></a> */
<a name="line433"></a>BaseTestChannel.prototype.shouldUseSecondaryDomains = function() {
<a name="line434"></a>  return this.channel_.shouldUseSecondaryDomains();
<a name="line435"></a>};
<a name="line436"></a>
<a name="line437"></a>
<a name="line438"></a>/**
<a name="line439"></a> * @override
<a name="line440"></a> */
<a name="line441"></a>BaseTestChannel.prototype.isActive = function() {
<a name="line442"></a>  return this.channel_.isActive();
<a name="line443"></a>};
<a name="line444"></a>
<a name="line445"></a>
<a name="line446"></a>/**
<a name="line447"></a> * @return {boolean} True if test stage 2 detected a non-buffered
<a name="line448"></a> *     channel early and early no buffering detection is enabled.
<a name="line449"></a> * @private
<a name="line450"></a> */
<a name="line451"></a>BaseTestChannel.prototype.checkForEarlyNonBuffered_ = function() {
<a name="line452"></a>  var ms = this.firstTime_ - this.startTime_;
<a name="line453"></a>
<a name="line454"></a>  // we always get Trident responses in separate calls to
<a name="line455"></a>  // onRequestData, so we have to check the time that the first came in
<a name="line456"></a>  // and verify that the data arrived before the second portion could
<a name="line457"></a>  // have been sent. For all other browser&#39;s we skip the timing test.
<a name="line458"></a>  return ChannelRequest.supportsXhrStreaming() ||
<a name="line459"></a>      ms &lt; BaseTestChannel.MIN_TIME_EXPECTED_BETWEEN_DATA_;
<a name="line460"></a>};
<a name="line461"></a>
<a name="line462"></a>
<a name="line463"></a>/**
<a name="line464"></a> * @override
<a name="line465"></a> */
<a name="line466"></a>BaseTestChannel.prototype.getForwardChannelUri = goog.abstractMethod;
<a name="line467"></a>
<a name="line468"></a>
<a name="line469"></a>/**
<a name="line470"></a> * @override
<a name="line471"></a> */
<a name="line472"></a>BaseTestChannel.prototype.getBackChannelUri = goog.abstractMethod;
<a name="line473"></a>
<a name="line474"></a>
<a name="line475"></a>/**
<a name="line476"></a> * @override
<a name="line477"></a> */
<a name="line478"></a>BaseTestChannel.prototype.correctHostPrefix = goog.abstractMethod;
<a name="line479"></a>
<a name="line480"></a>
<a name="line481"></a>/**
<a name="line482"></a> * @override
<a name="line483"></a> */
<a name="line484"></a>BaseTestChannel.prototype.createDataUri = goog.abstractMethod;
<a name="line485"></a>
<a name="line486"></a>
<a name="line487"></a>/**
<a name="line488"></a> * @override
<a name="line489"></a> */
<a name="line490"></a>BaseTestChannel.prototype.testConnectionFinished = goog.abstractMethod;
<a name="line491"></a>
<a name="line492"></a>
<a name="line493"></a>/**
<a name="line494"></a> * @override
<a name="line495"></a> */
<a name="line496"></a>BaseTestChannel.prototype.testConnectionFailure = goog.abstractMethod;
<a name="line497"></a>
<a name="line498"></a>
<a name="line499"></a>/**
<a name="line500"></a> * @override
<a name="line501"></a> */
<a name="line502"></a>BaseTestChannel.prototype.getConnectionState = goog.abstractMethod;
<a name="line503"></a>});  // goog.scope
</pre>


</body>
</html>
